function dataGroup = TimeAalignment(fid,num,time,type)
%获得了时间为：time处的数据
%有三种文件类型，所以有3个type参数设置：example、our、4nav
if(type=="example")
   
    while true
        
        Data = fread(fid, num, 'double');
        time = round(time*1000)/1000;%对时间的第三位小数处取整（某个时间可能是91620.0100000001，取整为91620.010）
        Time = round(Data(1)*1000)/1000;
        if (Time==time)
            dataGroup = Data;
            break;%时间对齐则跳出循环，获得该历元的数据
        end
    end

elseif(type=="our")
    while true
        tline = fgets(fid);%读取一行
        split_data = strsplit(tline,{',',';','*'});
        str1 = split_data(1);
        str2 = '%RAWIMUSA';
        Data=zeros(7,1);
        if(strcmp(str1, str2))
            try%存储为double类型
                Data(1) = str2double(split_data(3));%time
                Data(2) = str2double(split_data(12))*1.0E-09;%gyrox
                Data(3) = str2double(split_data(11))*1.0E-09*-1;%gyroy
                Data(4) = str2double(split_data(10))*1.0E-09;%gyroz
                Data(5) = str2double(split_data(9))*2.0E-08;%acclx
                Data(6) = str2double(split_data(8))*2.0E-08*-1;%accly
                Data(7) = str2double(split_data(7))*2.0E-08;%acclz
            catch
                disp('转换错误：该列包含非数值数据。');
            end
        end
        time = round(time*1000)/1000;
        Time=round(Data(1)*1000)/1000;
        if (Time==time)
            dataGroup = Data;
            break;%时间对齐则跳出循环，获得该历元的数据
        end
    end
elseif(type=="4nav")

    while true
        tline = fgets(fid);%读取一行
        split_data = strsplit(tline,{' ',':'});
        if(length(split_data)>10)
            str1 = split_data(2);           
        else
            str1 = "000";
        end
        str2 = '2337';
        Data=zeros(10,1);
        if(strcmp(str1, str2))
            try%存储为double类型
                Data(1) = str2double(split_data(3));%time
                Data(2) = str2double(split_data(4));%纬度
                Data(3) = str2double(split_data(5));%经度
                Data(4) = str2double(split_data(6));%高
                Data(5) = str2double(split_data(7));%北向速度
                Data(6) = str2double(split_data(8));%东向速度
                Data(7) = str2double(split_data(9));%地向速度
                Data(8) = str2double(split_data(10));%Phi
                Data(9) = str2double(split_data(11));%theta
                Data(10) = str2double(split_data(12));%psi
            catch
                disp('转换错误：该列包含非数值数据。');
            end
            time = round(time*1000)/1000;%解算使用的时间
            Time = round(Data(1)*1000)/1000;%参考时间
            if (abs(Time-time)<0.010)
                Data(1)   = time;
                dataGroup = Data;
                break;%时间对齐则跳出循环，获得该历元的数据;时间对不齐则往下寻找
            end
        end
  
    end
    if feof(fid)
        dataGroup= [];
        fprintf('%s\n','参考数据已到末尾，无法继续与解算数据对比');
    end
     
end



end